package com.xyj.domain;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by 徐宇健 on 2015/2/12 0012.
 */
@Entity
@Table(name = "T_menu", schema = "", catalog = "sshe")
public class TMenu {
    private String id;
    private String name;
    private String icon;
    private String url;
    private TMenu tMenuByTid;
    private Collection<TMenu> tMenusById;

    @Id
    @Column(name = "id", nullable = false, length = 36)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name" ,nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "icon")
    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    @Basic
    @Column(name = "url")
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TMenu tMenu = (TMenu) o;

        if (icon != null ? !icon.equals(tMenu.icon) : tMenu.icon != null) return false;
        if (id != null ? !id.equals(tMenu.id) : tMenu.id != null) return false;
        if (name != null ? !name.equals(tMenu.name) : tMenu.name != null) return false;
        if (url != null ? !url.equals(tMenu.url) : tMenu.url != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (icon != null ? icon.hashCode() : 0);
        result = 31 * result + (url != null ? url.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "tid", referencedColumnName = "id")
    public TMenu gettMenuByTid() {
        return tMenuByTid;
    }

    public void settMenuByTid(TMenu tMenuByTid) {
        this.tMenuByTid = tMenuByTid;
    }

    @OneToMany(mappedBy = "tMenuByTid")
    public Collection<TMenu> gettMenusById() {
        return tMenusById;
    }

    public void settMenusById(Collection<TMenu> tMenusById) {
        this.tMenusById = tMenusById;
    }

}
